package cart;

import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.tedu.store.bean.Cart;
import cn.tedu.store.mapper.CartMapper;
import cn.tedu.store.service.CartService;

public class carttest {
	@Test
	public void addCart(){
		AbstractApplicationContext ac=new ClassPathXmlApplicationContext("spring-dao.xml","spring-service.xml");
		CartService cs=ac.getBean("cartService",CartService.class);
		Cart c=new Cart();
		c.setCount(1);
		c.setGoodsid("10000000");
		c.setUserid(10000000);
		cs.addCart(c);
	}
	@Test
	public void selectAll(){
		AbstractApplicationContext ac=new ClassPathXmlApplicationContext("spring-dao.xml","spring-service.xml");
		CartMapper cs=ac.getBean("cartMapper",CartMapper.class);
		System.out.println(cs.selectAll(10000000));
	}
	@Test
	public void deleteByCartId(){
		AbstractApplicationContext ac=new ClassPathXmlApplicationContext("spring-dao.xml","spring-service.xml");
		CartMapper cs=ac.getBean("cartMapper",CartMapper.class);
		cs.deleteByCartId(11);
	}
}